package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

/*
反射机制访问注解参数

 */
public class ReflectDemo8 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        /*
        获取Person类中sayHello方法上的注解@AutoRunMethod中的参数值
         */
        Class cls=Class.forName("reflect.Person");
        Method method=cls.getDeclaredMethod("sayHello");

        if(method.isAnnotationPresent(AutoRunMethod.class)){
            AutoRunMethod arm=method.getAnnotation(AutoRunMethod.class);
            int value = arm.value();
            System.out.println("参数value的值为"+value);
        }

    }
}
